package cn.com.pansky.task;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimerTask;

import org.apache.log4j.Logger;

import cn.com.pansky.service.OrderService;
import cn.com.pansky.util.DateUtil;

public class QueryOrderTask extends TimerTask{
	protected static Logger logger = Logger.getLogger(QueryOrderTask.class);
	private String orderNumber;
	private String bab502;
	private Boolean status;
	private String megId; //商户ID
	private String createTime; //订单生成时间
	private String endTime; //定时器结束时间 订单时间推后 30 分钟
	private String cardId; //身份证号码
	private String aae001;
	
	
	public String getAae001() {
		return aae001;
	}


	public void setAae001(String aae001) {
		this.aae001 = aae001;
	}


	public String getCardId() {
		return cardId;
	}


	public void setCardId(String cardId) {
		this.cardId = cardId;
	}


	public String getOrderNumber() {
		return orderNumber;
	}


	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}


	public String getBab502() {
		return bab502;
	}


	public void setBab502(String bab502) {
		this.bab502 = bab502;
	}


	public Boolean getStatus() {
		return status;
	}


	public void setStatus(Boolean status) {
		this.status = status;
	}


	public String getMegId() {
		return megId;
	}


	public void setMegId(String megId) {
		this.megId = megId;
	}


	public String getCreateTime() {
		return createTime;
	}


	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}


	public String getEndTime() {
		return endTime;
	}


	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}


	@Override
	public void run() {
		System.out.println(DateUtil.current19Time()+"*********开始执行任务*************");
		OrderService os = new OrderService();
		os.setCa006(this.getCardId());
		os.setAae011(this.getAae001());
		try {
			if(os.orderQuery(this.getBab502(), this.getOrderNumber(), this.getMegId())){
				System.out.println("*********订单状态回填成功，任务结束*************");
				this.cancel();
			}
			 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
		     Date date1 = sdf.parse(this.getEndTime());  
		     Date date2 = sdf.parse(DateUtil.current19Time());  
		     long l = date2.getTime() - date1.getTime();
			if(l>0) {
				System.out.println(DateUtil.current19Time()+"*********超过30分钟，任务结束*************");
				this.cancel();
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
}
